import type { FcPageConfig } from '@/types/fcform'
import { createFormItems } from './edit/formItems.ts'
import { createRules } from './edit/rules.ts'
import { createColums } from './table/columns.ts'

export function usePageConfig(): FcPageConfig {
  return {
    KEY: 'postId',
    pageProps: {
      tools: {
        add: {
          auth: 'sys_post_add',
        },
        del: {
          auth: 'sys_post_del',
        },
      },
    },
    table: {
      getApi: '/admin/post/page',
      delApi: {
        api: '/admin/post',
        method: 'delete',
        isArray: true,
      },
      createColums,
      props: {
        scrollX: 1576,
      },
    },
    edit: {
      default: {
        addApi: '/admin/post',
        editApi: {
          api: '/admin/post',
          method: 'put',
        },
        defaultValue: {
          sortOrder: 1,
        },
        createItems: createFormItems,
        createRule: createRules,
      },
    },
  }
}
